package cn.stu.projectsummit.admin.controller;

import cn.stu.projectsummit.admin.pojo.dto.AdminLoginParam;
import cn.stu.projectsummit.admin.pojo.vo.AdminVO;
import cn.stu.projectsummit.admin.service.AdminService;
import cn.stu.projectsummit.base.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("v1/admin")
public class AdminController {
    @Autowired
    AdminService adminService;
    @PostMapping("login")
    public JsonResult login(@RequestBody AdminLoginParam adminLoginParam) {
        log.debug("用户登录:adminLoginParam={}",adminLoginParam);
        //调用业务层方法,如果业务层方法成功执行完毕,可以拿到业务层返回的usrVO
        AdminVO adminVO = adminService.login(adminLoginParam);
        //控制层向前端返回登录成功后的完整用户信息userVO
        //将查到的userVO装到.ok()中一起返回给前端
        return JsonResult.ok(adminVO);
    }
}
